<?php
namespace app\admin\model;
use think\Model;
use think\Db;
class Order extends Model
{
	//订单明细列表
	public function index(){
		$all = input('get.all');
		$key = input('get.key');
		//显示全部数据
		if($all == 1){

           $data = DB::table('ma_order')->alias('a')->join('ma_users b','a.uid = b.uid')->field('b.username,a.*')->order('oid desc')->select();
		}else{

			$startime = input('get.startime');
			$endtime = input('get.endtime');

			if($startime and $endtime){
				$data = DB::table('ma_order')->alias('a')->join('ma_users b','a.uid = b.uid')->field('b.username,a.*')->where('a.ordertime','between',[$startime,$endtime])->order('oid desc')->paginate(1000);
			}else{
				$data = DB::table('ma_order')->alias('a')->join('ma_users b','a.uid = b.uid')->field('b.username,a.*')->where('b.username|a.qishu','like',"%".$key."%")->order('oid desc')->paginate(15);
			}
		   // $data = DB::table('ma_order')->alias('a')->join('ma_users b','a.uid = b.uid')->field('b.username,a.*')->where('b.username|a.qishu','like',"%".$key."%")->order('oid desc')->paginate(15);
		}
		return $data;
	}
}